<?php

namespace common\repositories\myhtsq;

use Yii;
use common\error\ErrorCode;
use common\entities\myhtsq\RoleEntity;
use common\repositories\BaseRepository;

class RoleRepository extends BaseRepository {

    /**
     * 构造方法
     * @param unknown $config (optional)
     */
    public function __construct($config = []) {
        parent::__construct($config);
    }

    /**
     * 获取角色列表
     * @param int $orgId 商家id
     * @return array
     */
    public static function getRoleList($orgId) {
        return RoleEntity::find()->where(['organization_id' => $orgId])->all();
    }

    /**
     * 根据角色id 获取角色role model 
     * @param int $roleId 角色id
     * @return \common\models\auth\Role
     */
    public static function getRoleByRoleId($roleId) {
        return RoleEntity::find()->where(['role_id' => $roleId, 'is_delete' => 0])->one();
    }

    public function checkRoleExit($role_id)
    {
        return RoleEntity::find()->where(['role_id' => $role_id])->one();
    }

}
